# -*- coding: utf-8 -*-
"""
Created on Thu Nov 17 21:53:55 2022

@author: YSL
"""

num=int(input("请输入正整数："))
num_record=num

for j in range(1000):
    num_o=[0]*5
    for i in range(5):
        num_o[i]=num%10
        num=num//10
    num=0
    for i in range(5):
        num+=pow(num_o[i],2)
    if num==1:
        print("True")
        break
if num!=1:
    print("False")